<h3>Merge Duplicate Records</h3>
<% form_remote_tag :url => {:action => 'commit_merge', :keeper_id => @person.id, :duplicate_id => @duplicate} do %>

<div style="float:none;clear:both">


<table border="1" cellspacing="0" cellpadding="4" width="100%">
	<tr style="background-color:#536A97;color:#FFFFFF;">
		<th>
				<label>This is the keeper:</label>
				<h3><%= @person.full_name %> (#<%= @person.id %>)</h3>
		</th>
		<th>
			<label>Ditching this record:</label>
			<h3 id="dup-h3"></h3>
		</th>
	</tr>
	
	<tr>
		<td>	
		</td>
		<td>
			<div id="search-panel" style="size:12px;text-align:left;">
				<% form_remote_tag :url => {:action => 'search_for_duplicates'} do %>
				<span id='progress' style='display:none;float:right;'><img src='/images/working.gif'></span>
				<label>Last, First Name:</label><br>
				<%= text_field_tag :person_name %>
				<%= submit_to_remote 'SearchBtn', 'Search', :url => {:action => 'search_for_duplicates', :orginal_id => @person.id } %>
				<% end %>
			</div>
			<div id="results-panel" style="size:12px;text-align:left;font-weight:normal;background-color:#f4ebc4;">
				
			</div>
		</td>
	</tr>
		
	<tr>
		<td>
			<div>
				<strong>Household Info</strong> (moved into)
			</div>
			<div>
				<span><%= @person.household.household_name rescue nil %> (#<%= @person.household.id %>)</span><br>
				<span><%= @person.household.address_block %></span><br>
				<span><strong>Household People:</strong> <%= @person.household.people.collect {|p| p.first_name}.to_sentence rescue nil %></span>
			</div>
		</td>
		<td>
			<div id="household-area">
				<%= render :partial => "dup_household" unless @duplicate.nil? or @duplicate.household.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<strong>Individual Info</strong>
			<table border="0" cellspacing="0" cellpadding="1" width="100%">
				<tr>
					<td><label>Birthdate:</label></td>
					<td><label>Checkin Group:</label></td>
				</tr>
				<tr>
					<td>
						<%= @person.birthdate.strftime('%m/%d/%Y') rescue nil %>
					</td>
					<td>
						<%= @person.default_group.name rescue nil %>
					</td>
				</tr>
				<tr>
					<td><label>Gender:</label></td>
					<td><label>Household Position:</label></td>
				</tr>
				<tr>
					<td>
						<%= @person.gender rescue nil %>
					</td>
					<td>
						<%= @person.household_position rescue nil %>
					</td>
				</tr>
			</table>
		</td>
		<td>
			<div id="individual-area">
				<%= render :partial => "dup_individual" unless @duplicate.nil? or @duplicate.household.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong>Phones</strong><span id="message-black"> (Only checked values will be retained)</span></div>
			<% @person.phones.each do |p| %>
			<div>
				<%= check_box_tag 'phones[]', p.id %>
				<%= number_to_phone p.number %>
			</div>
			<% end %>
		</td>
		<td>
			<div id="phone-area">
				<%= render :partial => "dup_phones" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong>Emails</strong><span id="message-black"> (Only checked values will be retained)</span></div>
			<% @person.emails.each do |e| %>
			<div>
				<%= check_box_tag 'emails[]', e.id %>
				<%= e.email %>
			</div>
			<% end %>
		</td>
		<td>
			<div id="email-area">
				<%= render :partial => "dup_emails" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
				<div><strong>Enrolled In</strong></div>
				<% @person.enrollments.each do |e| %>
				<div>
					<%= e.group.name rescue nil %>
				</div>
				<% end %>
		</td>
		<td>
			<div id="enrollment-area">
				<%= render :partial => "dup_enrollments" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong>Involved In</strong></div>
			<% @person.involvements.each do |i| %>
			<div>
				<%= i.job.team.name rescue nil %> (<%= i.job.title rescue nil %>)
			</div>
			<% end %>
		</td>
		<td>
			<div id="involvement-area">
				<%= render :partial => "dup_involvements" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong># Attendances</strong></div>
			<div>
				<%= @person.attendances.length rescue nil %>
			</div>
		</td>
		<td>
			<div id="attendances-area">
				<%= render :partial => "dup_attendances" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong>Contacts</strong></div>
			<% @person.contacts.sort_by(&:created_at).each do |c| %>
			<div><%= c.created_at.strftime('%m/%d/%Y') rescue nil %> <%= c.contact_type.name rescue nil %></div>
			<% end %>
		</td>
		<td>
			<div id="contacts-area">
				<%= render :partial => "dup_contacts" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong>Tags</strong></div>
			<% @person.taggings.each do |t| %>
			<div>
				<%= t.tag.tag_group.name rescue nil %>: <%= t.tag.name rescue nil %>
			</div>
			<% end %>
		</td>
		<td>
			<div id="tags-area">
				<%= render :partial => "dup_tags" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
	
	<tr>
		<td>
			<div><strong># Contributions</strong></div>
			<div>
				<%= @person.contributions.length rescue nil %>
			</div>
		</td>
		<td>
			<div id="contributions-area">
				<%= render :partial => "dup_contributions" unless @duplicate.nil? %>
			</div>
		</td>
	</tr>
</table>
	
	
</div>

<div id="duplicate-info">
	<%= render :partial => "dup_id" %>
</div>
<%= submit_tag 'Merge Records' %>
<% end %>

<div style="float:none;clear:both;">
	<br>
</div>